package com.dzm.xgb.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dzm.xgb.core.pojo.entity.UserLoginRecord;
import com.dzm.xgb.core.mapper.UserLoginRecordMapper;
import com.dzm.xgb.core.service.UserLoginRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户登录记录表 服务实现类
 * </p>
 *
 * @author Dzm
 * @since 2024-08-27
 */
@Service
public class UserLoginRecordServiceImpl extends ServiceImpl<UserLoginRecordMapper, UserLoginRecord> implements UserLoginRecordService {

    @Override
    public List<UserLoginRecord> listByUserId(Integer id) {
        List<UserLoginRecord> list = this.list(new LambdaQueryWrapper<UserLoginRecord>()
                .eq(UserLoginRecord::getUserId, id)
                .orderByDesc(UserLoginRecord::getCreateTime)
                .last(" limit 5"));
        return list;
    }
}
